home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5500 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  39 lines

  1. Path: uuneo.neosoft.com!usenet
  2. From: reynolds@neosoft.com
  3. Newsgroups: comp.lang.c++
  4. Subject: need help on VERY simple program. I am a beginner, so this is an easy question!!!
  5. Date: Sun, 04 Feb 1996 22:41:23 -0600
  6. Organization: NeoSoft Internet Services   +1 713 968 5800
  7. Message-ID: <31158A73.3B43@neosoft.com>
  8. NNTP-Posting-Host: tuffy-ppp-f4.neosoft.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b6a (Win95; I)
  13. CC: reynolds@neosoft.com
  14.  
  15. To anyone out there please tell me how to use the ternary operator (?:)
  16. underneath an if else statement.  I am having trouble eliminating a line 
  17. of text when I do not want it there.  Here is my program:
  18. //Calculator(is just a practice program I made up)
  19. #include <iostream.h>
  20.  
  21. main ()
  22. {
  23.     long integer1, integer2, sum, difference, product, quotient;
  24.     cout << "enter first integer\n";
  25.     cin >> integer1;
  26.     cout << "enter second integer\n";
  27.     cin >> integer2;
  28.     if (integer1 == integer2)
  29.         cout << "These two numbers are equal!!\n";
  30.     if (integer1 > integer2)
  31.         cout << "First integer greater than second!!\n";
  32.     else
  33. //This is the statement which I want to clear IF integer1 == integer2    
  34.         cout << "Second integer greater than first!!\n";
  35. and so on. . . 
  36. Please answer by writing to me at reynolds@neosoft.com
  37. I would appreciate any answer I receive.  Thanks so much,
  38.                  ---John Reynolds
  39.